package ru.vsu.cs.pm.models;

import javax.persistence.*;
import java.io.Serializable;

/**
 * User: Oleg
 * Date: 19.12.2010
 */
@Entity
@Table(name = "public_user",
    uniqueConstraints = {@UniqueConstraint(columnNames = "user_name")})
@NamedQueries({
        @NamedQuery(name = "user.find.all", query = "select u from User u order by u.id"),

        @NamedQuery(name = "user.authenticate",
                query = "select u from User u " +
                        "where u.userName = :userName order by u.id")
})
public class User implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    private Integer id;

    @Column(name = "user_name", unique = true, nullable = false, length = 64)
    private String userName;

    @Column(name = "password_hash", nullable = false, length = 50)
    private String passwordHash;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPasswordHash() {
        return passwordHash;
    }

    public void setPasswordHash(String passwordHash) {
        this.passwordHash = passwordHash;
    }
}
